﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace WPF.Element.UI.Communal
{
    /// <summary>
    /// 使用资源
    /// </summary>
    internal class UserResource
    {
        /// <summary>
        /// 获取动态资源
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="resourceKey">动态资源的Key</param>
        /// <returns></returns>
        public static T GetDynamicResources<T>(string resourceKey)
        {
            object resource = Application.Current.Resources[resourceKey];
            if (resource == null) 
            {
                return default(T);  // 获取当前类型的默认值
            }
            return (T)resource; // 返回正式的值
        }

    }
}
